Null Suspicious Reference (NSR)

Description:

NSR detects situations when a reference is dereferenced without checking for null but in another context such check is performed, so it is assumed that the reference can contain a null value.

Incorrect:

public void printMessage(Message msg) {
    msg.print();
    if (msg != null) {
        ...
    }
}

Correct:

public void printMessage(Message msg) {
    if (msg != null) {
        msg.print();
        ...
    }
}